// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
 * @file calculatorTypeObjectSupport.cxx
 * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file
 *
 * This file was generated by the tool fastddsgen (version: 4.1.0).
 */

#include "calculatorTypeObjectSupport.hpp"

#include <mutex>
#include <string>

#include <fastcdr/xcdr/external.hpp>
#include <fastcdr/xcdr/optional.hpp>
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/log/Log.hpp>
#include <fastdds/dds/xtypes/common.hpp>
#include <fastdds/dds/xtypes/type_representation/ITypeObjectRegistry.hpp>
#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>
#include <fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp>

#include "calculator.hpp"

using namespace eprosima::fastdds::dds::xtypes;

namespace calculator_example {

void register_FilterKind_type_identifier(TypeIdentifierPair& type_ids_FilterKind)
{
    ReturnCode_t return_code_FilterKind {eprosima::fastdds::dds::RETCODE_OK};
    return_code_FilterKind = eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( "calculator_example::FilterKind", type_ids_FilterKind);
    if (eprosima::fastdds::dds::RETCODE_OK != return_code_FilterKind)
    {
        EnumTypeFlag enum_flags_FilterKind = 0;
        BitBound bit_bound_FilterKind = 32;
        CommonEnumeratedHeader common_FilterKind = TypeObjectUtils::build_common_enumerated_header(bit_bound_FilterKind);
        QualifiedTypeName type_name_FilterKind = "calculator_example::FilterKind";
        eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_FilterKind;
        eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_FilterKind;
        CompleteTypeDetail detail_FilterKind = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_FilterKind, ann_custom_FilterKind, type_name_FilterKind.to_string());
        CompleteEnumeratedHeader header_FilterKind = TypeObjectUtils::build_complete_enumerated_header(common_FilterKind, detail_FilterKind);
        CompleteEnumeratedLiteralSeq literal_seq_FilterKind;
        {
            EnumeratedLiteralFlag flags_EVEN = TypeObjectUtils::build_enumerated_literal_flag(false);
            CommonEnumeratedLiteral common_EVEN = TypeObjectUtils::build_common_enumerated_literal(0, flags_EVEN);
            eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_EVEN;
            ann_custom_FilterKind.reset();
            MemberName name_EVEN = "EVEN";
            CompleteMemberDetail detail_EVEN = TypeObjectUtils::build_complete_member_detail(name_EVEN, member_ann_builtin_EVEN, ann_custom_FilterKind);
            CompleteEnumeratedLiteral literal_EVEN = TypeObjectUtils::build_complete_enumerated_literal(common_EVEN, detail_EVEN);
            TypeObjectUtils::add_complete_enumerated_literal(literal_seq_FilterKind, literal_EVEN);
        }
        {
            EnumeratedLiteralFlag flags_ODD = TypeObjectUtils::build_enumerated_literal_flag(false);
            CommonEnumeratedLiteral common_ODD = TypeObjectUtils::build_common_enumerated_literal(1, flags_ODD);
            eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_ODD;
            ann_custom_FilterKind.reset();
            MemberName name_ODD = "ODD";
            CompleteMemberDetail detail_ODD = TypeObjectUtils::build_complete_member_detail(name_ODD, member_ann_builtin_ODD, ann_custom_FilterKind);
            CompleteEnumeratedLiteral literal_ODD = TypeObjectUtils::build_complete_enumerated_literal(common_ODD, detail_ODD);
            TypeObjectUtils::add_complete_enumerated_literal(literal_seq_FilterKind, literal_ODD);
        }
        {
            EnumeratedLiteralFlag flags_PRIME = TypeObjectUtils::build_enumerated_literal_flag(false);
            CommonEnumeratedLiteral common_PRIME = TypeObjectUtils::build_common_enumerated_literal(2, flags_PRIME);
            eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_PRIME;
            ann_custom_FilterKind.reset();
            MemberName name_PRIME = "PRIME";
            CompleteMemberDetail detail_PRIME = TypeObjectUtils::build_complete_member_detail(name_PRIME, member_ann_builtin_PRIME, ann_custom_FilterKind);
            CompleteEnumeratedLiteral literal_PRIME = TypeObjectUtils::build_complete_enumerated_literal(common_PRIME, detail_PRIME);
            TypeObjectUtils::add_complete_enumerated_literal(literal_seq_FilterKind, literal_PRIME);
        }
        CompleteEnumeratedType enumerated_type_FilterKind = TypeObjectUtils::build_complete_enumerated_type(enum_flags_FilterKind, header_FilterKind, literal_seq_FilterKind);
        if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == TypeObjectUtils::build_and_register_enumerated_type_object(enumerated_type_FilterKind, type_name_FilterKind.to_string(), type_ids_FilterKind))
        {
            EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "calculator_example::FilterKind already registered in TypeObjectRegistry for a different type.");
        }
    }
}

} // namespace calculator_example

